#pragma once
#include <iostream>
#include <unistd.h>
#include <fcntl.h>
#include <vector>
namespace ns_until {

	//设置文件描述符为非阻塞状态
	void SetNoBlock(int sock) {
		int f1 = fcntl(sock, F_GETFL);
		fcntl(sock, F_SETFL, f1 | O_NONBLOCK);
	}
    class StringUtil {
	public:
		static void Split(std::string& in, std::vector<std::string>* out,std::string sep) {
			//sssssssXfffffffffffXaaaaaaaaX
			//sssssssssXffffffXaaaa
			//ssss
			//""
			while (true) {
				size_t pos = in.find(sep);
				if (pos == std::string::npos) {
					break;
				}

				std::string s = in.substr(0, pos);
				out->push_back(s);
				in.erase(0,pos+sep.size());

			}
		}
        static void Deserialize(std::string& in, int* x, int* y) {
			ssize_t pos = in.find('+');
			std::string left = in.substr(0, pos);
			std::string right = in.substr(pos + 1);

			*x = atoi(left.c_str());
			*y = atoi(right.c_str());


		}
	};
}
